package cn.thoughtworks.school.programCenter.repositories;

import cn.thoughtworks.school.programCenter.entities.UserTag;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import javax.transaction.Transactional;
import java.util.List;

public interface UserTagRepository extends JpaRepository<UserTag, Long> {
    List<UserTag> findByProgramIdAndStudentId(Long programId, Long studentId);

    void deleteByTagId(Long tagId);


    @Modifying
    @Transactional
    @Query("delete from UserTag where programId=?1 and studentId=?2")
    void deleteByProgramIdAndStudentId(Long programId, Long studentId);
}
